#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
void solve()
{
    ll n;
    while (cin >> n)
    {
        if (n == 0)
        {
            cout << 0 << endl;
            continue;
        }
        queue<bool> que;
        bool nIsNegative = 0;
        if (n < 0)
        {
            n *= -1;
            nIsNegative = 1;
        }
        while (n)
        {
            que.push((n + nIsNegative) % 2);
            n = n / 2;
        }
        int count = 0;
        int countRest = 63;
        if (!nIsNegative)
            while (!que.empty())
            {
                if (que.front() == 1)
                    count++;
                que.pop();
            }
        else
        {
            count++;
            bool temp = 1;
            while (!que.empty())
            {
                if (que.front() == 1)
                {
                    if (temp == 0)
                        count++;
                }
                else if (temp == 1)
                {
                    temp = 0;
                    count++;
                }
                countRest--;
                que.pop();
            }
            count += countRest;
        }
        cout << count << endl;
    }
}
int main()
{
    solve();
    return 0;
}
